package com.atchangsha.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atchangsha.system.common.utils.PageUtils;
import com.atchangsha.system.common.utils.Query;
import com.atchangsha.system.dao.MenusDao;
import com.atchangsha.system.entity.MenusEntity;
import com.atchangsha.system.service.MenusService;
import org.springframework.util.StringUtils;

@Service("menusService")
public class MenusServiceImpl extends ServiceImpl<MenusDao, MenusEntity> implements MenusService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        LambdaQueryWrapper<MenusEntity> wrapper = new LambdaQueryWrapper<>();
        String key = (String)params.get("key");
        if(!StringUtils.isEmpty(key)){
            wrapper.like(MenusEntity::getName,key).or().like(MenusEntity::getType,key);
        }
        IPage<MenusEntity> page = this.page(
                new Query<MenusEntity>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }

}